import { createApp } from 'vue'
//import './style.css'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router/index'
import { createPinia } from 'pinia';

function getRoleAry(router){
   let roleAry=[]
   let routes= router.getRoutes();//获取所有路由配置
   routes.forEach(r=>{
     if(r.meta&&r.meta.roles)//如果有roles的配置的话
       roleAry[r.path]=r.meta.roles;//把它存入字典，key是网址，value是角色内容
   })
   return roleAry;
 }
 const roleAry=getRoleAry(router);//获取了所有有权限要求的数组，key是网址，value是权限

const app=createApp(App)
app.provide("roleAry",roleAry)//发布到了组件树，子孙组件都能访问它
app.use(ElementPlus)
app.use(router)
app.use(createPinia())
app.mount('#app')
